package com.xxl.rpc.sample.server.service;

import com.xxl.rpc.core.remoting.invoker.XxlRpcInvokerFactory;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Component;

@Component
public class KafkaConsumerService {
    private static Logger logger = LoggerFactory.getLogger(KafkaConsumerService.class);

    //消费者：监听topic02,group02
    @KafkaListener(topics = {"kunlog"},groupId = "group02")
    public void consumer(ConsumerRecord<Integer,String> record, Acknowledgment acknowledgment) throws InterruptedException {
        logger.info("consumer2 kfk consume message topic:{},msg:{}",record.topic(),record.value());
        Thread.sleep(10000);
        //收工签收机制
        acknowledgment.acknowledge();
        logger.info("========================");
    }

}
